package com.tjhzzx.ibmsSupervisor;

import com.tridium.hx.BHandheldHxProfile;

import javax.baja.agent.AgentFilter;
import javax.baja.file.BFileSystem;
import javax.baja.file.FilePath;
import javax.baja.naming.BOrd;
import javax.baja.naming.OrdQuery;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import java.io.File;

/**
 * Created by Luc on 2018/11/4.
 * <p>
 * <p>
 * 提供与velocity页面交互的接口
 */

//@NiagaraType
public class BIbmsHandheldHxProfile extends BHandheldHxProfile {
    /*+ ------------ BEGIN BAJA AUTO GENERATED CODE ------------ +*/
    /*@ $com.tju.tculabSupervisor.BIbmsHandheldHxProfile(2979906276)1.0$ @*/
    /* Generated Sun Nov 04 11:45:47 CST 2018 by Slot-o-Matic (c) Tridium, Inc. 2012 */

////////////////////////////////////////////////////////////////
// Type
////////////////////////////////////////////////////////////////

    public static final BIbmsHandheldHxProfile INSTANCE = new BIbmsHandheldHxProfile();

    @Override
    public Type getType() {
        return TYPE;
    }

    public static final Type TYPE = Sys.loadType(BIbmsHandheldHxProfile.class);

    /*+ ------------ END BAJA AUTO GENERATED CODE -------------- +*/

//    private static final Logger LOGGER = Logger.getLogger(BIbmsHandheldHxProfile.class.getName());

    public static AgentFilter makeAgentFilter(String agentTypeSpec) {
        return AgentFilter.is(agentTypeSpec);
    }

//    public static List<HistoryTreeParam> getHistoryParams(BTreeMenuItem treeMenuItem) {
//        List<HistoryTreeParam> historyParams = HistoryManager.getHistoryTreeItems(treeMenuItem);
//        return historyParams;
//    }
//
//    public static String convertToHistoryOrd(BOrd ord) {
//        BHistory fxh = null;
//        if(ord == null) {
//            return null;
//        }
//        try {
//            fxh = (BHistory) ord.resolve().get();
//        } catch (Exception e) {
//            return null;
//        }
//        return fxh.getId().toString();
//    }

    public static String getFilePath(String ord) {
        BOrd fileOrd = BOrd.make(ord);
        OrdQuery[] queries = fileOrd.parse();
        FilePath filePath = (FilePath) queries[queries.length - 1];
        File file = BFileSystem.INSTANCE.pathToLocalFile(filePath);
//        String path = file.getAbsolutePath().replace("\\", "/");
        return file.getAbsolutePath();
    }
}
